<?php


namespace App\Controller\api\v1;

use App\Common\Res;
use App\Controller\AbstractController;
use App\Rpc\api\impl\UserImpl;
use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class UserController extends AbstractController
{
    use Res;

    /**
     * 获取客服相关运营号信息
     * @return array
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getWorkerInfo(): array
    {
        $params = $this->request->all();
        return ApplicationContext::getContainer()->get(UserImpl::class)->getAppOperationList($params);
    }

    /**
     * 获取运营号联系人列表
     * @return array
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getContactsList(): array
    {
        $params = $this->request->all();
        return ApplicationContext::getContainer()->get(UserImpl::class)->getContactsList($params);
    }

    /**
     * 获取运营号下群列表
     * @return array
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getGroupList(): array
    {
        $params = $this->request->all();
        $res["code"] = 200;
        $res["total"] = 20;

        $groups['avatarUrl'] = "";
        $groups['extType'] = 1; //或者0
        $groups['chatId'] = 1;

        for ($i = 0; $i < 20; $i++) {
            $groups['name'] = "群" . $i;
            $res["rows"][] = $groups;
        }

        return $res;
    }

    /**
     * 设置好友备注
     * @return array
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function remark(): array
    {
        $params = $this->request->all();
        return ApplicationContext::getContainer()->get(UserImpl::class)->setRemark($params);
    }


}